package com.kb.design.service.impl;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.kb.design.dto.DesignFileDTO;
import com.kb.design.entity.DesignFile;
import com.kb.design.mapper.postgreSQL.DesignFileMapper;
import com.kb.design.service.DesignFileService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 附件表 服务实现类
 * </p>
 *
 * @author author
 * @since 2023-11-14
 */
@Service
@DS("slave-1")
public class DesignFileServiceImpl extends ServiceImpl<DesignFileMapper, DesignFile> implements DesignFileService {

    @Autowired
    private DesignFileMapper designFileMapper;
    @Override
    public Page<DesignFile> queryByPage(DesignFileDTO designFileDTO) {
        Page<DesignFile> page = new Page<>(designFileDTO.getPageNo(), designFileDTO.getPageSize());
        LambdaQueryWrapper<DesignFile> query = new LambdaQueryWrapper<>();
        query.eq(DesignFile::getDesignId,designFileDTO.getDesignId());
        return designFileMapper.selectPage(page,query);
    }

    @Override
    public List<DesignFile> queryById(Long id) {
        //根据 designId查询
            LambdaQueryWrapper<DesignFile> query = new LambdaQueryWrapper<>();
            query.eq(DesignFile::getDesignId,id);
            return designFileMapper.selectList(query);
    }
}
